import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:razer_one/app/main/constants/color_constants.dart';
import 'package:razer_one/app/modules/root/root_controller.dart';

class RootPage extends GetView<RootController> {
  const RootPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<RootController>(builder: (_) {
      return Scaffold(
        backgroundColor: Colors.white,
        body: IndexedStack(
          index: _.currentIndex,
          children: _.pages,
        ),
        bottomNavigationBar: BottomNavigationBar(
          selectedItemColor: const Color(kTabbarBlueColor),
          unselectedItemColor: const Color(kGrayColor),
          items: _.rootList
              .map(
                (e) => BottomNavigationBarItem(
                    label: e.title,
                    icon: Image.asset(
                      e.icon,
                      width: 32,
                      gaplessPlayback: true,
                    ),
                    activeIcon: Image.asset(
                      e.activeIcon,
                      width: 32,
                      gaplessPlayback: true,
                    )),
              )
              .toList(),
          type: BottomNavigationBarType.fixed,
          currentIndex: _.currentIndex,
          selectedFontSize: 12,
          unselectedFontSize: 12,
          onTap: _.currentIndexChanged,
        ),
      );
    });
  }
}
